﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MailOut.aspx.cs" Inherits="InformationSystem.WebSite.Module.MailMgr.MailOut" %>

<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript">
        function callback() {
            parent.ResizeFrameHeight(GridPanel1.getHeight());
            //parent.ResizeFrameHeight(ViewPort1.getHeight(500));
        }
    </script>
    <style type="text/css">
        .x-grid3-cell-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid-group-hd div
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid3-hd-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
            font-size: 12px;
        }
        
        .x-grid3-body .x-grid3-td-Cost
        {
            background-color: #f1f2f4;
        }
        
        .x-grid3-summary-row .x-grid3-td-Cost
        {
            background-color: #e1e2e4;
        }
        
        .total-field
        {
            background-color: #fff;
            font-weight: bold !important;
            color: #000;
            border: solid 1px silver;
            padding: 2px;
            margin-right: 5px;
        }
    </style>
    <script type="text/javascript">
        var updateTotal = function (grid) {
            var fbar = grid.getBottomToolbar(),
                column,
                field,
                width,
                data = {},
                c,
                cs = grid.view.getColumnData();

            for (var j = 0, jlen = grid.store.getCount(); j < jlen; j++) {
                var r = grid.store.getAt(j);

                for (var i = 0, len = cs.length; i < len; i++) {
                    c = cs[i];
                    column = grid.getColumnModel().columns[i];

                    if (column.summaryType) {
                        data[c.name] = Ext.grid.GroupSummary.Calculations[column.summaryType](data[c.name] || 0, r, c.name, data);
                    }
                }
            }
        }
        var removeMailOut = function () {
            var grid = GridPanel1;
            grid.deleteSelected();
            mailStore.save();
        }
        function callback() {
            parent.ResizeFrameHeight(GridPanel1.getHeight());
        }

        function linkRenderer(value, meta, record) {
            return String.format("<div style='cursor: pointer;font-size:13;' onclick='window.location.href(\"MailContentView.aspx?mailid={0}\")'><a>{1}</a></div>", record.data.mailid, value);
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager runat="server">
        <Listeners>
            <DocumentReady Fn="callback()" />
        </Listeners>
    </ext:ResourceManager>
    <ext:GridPanel ID="GridPanel1" runat="server" Frame="true" StripeRows="true" Title="发件箱"
        AutoExpandColumn="mailsubject"  AnimCollapse="false" Icon="EmailStar"
        TrackMouseOver="false" Width="650" Height="450">
        <Store>
            <ext:Store ID="mailStore" runat="server" GroupOnSort="false" GroupField="grouptip"
                RemoteSort="true" OnBeforeRecordDeleted="BeforeRecordDeleted" OnAfterStoreChanged="AfterStoreChanged">
                <SortInfo Direction="DESC" Field="sendtime" />
                <Reader>
                    <ext:JsonReader IDProperty="MailID">
                        <Fields>
                            <ext:RecordField Name="mailid" Mapping="MailID" Type="Int" />
                            <ext:RecordField Name="mailsubject" Mapping="MailSubject" Type="String" />
                            <ext:RecordField Name="senduserid" Mapping="SendUserID" Type="String" />
                            <ext:RecordField Name="sendusername" Mapping="SendUserName" Type="String" />
                            <ext:RecordField Name="hasattachment" Mapping="HasAttachment" Type="Boolean" />
                            <ext:RecordField Name="createtime" Mapping="CreateTime" Type="Date" />
                            <ext:RecordField Name="sendtime" Mapping="SendTime" Type="Date" />
                            <ext:RecordField Name="recvusername" Mapping="RecvUserNameList" Type="String" />
                            <ext:RecordField Name="grouptip" Mapping="GroupTip" Type="String" />

                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>
        </Store>
        <ColumnModel runat="server">
            <Columns>
                <ext:Column DataIndex="grouptip" />
                <ext:Column ColumnID="recvusername" Header="收件人" DataIndex="recvusername" Width="50">
                    <Renderer Fn="linkRenderer" />
                </ext:Column>
                <ext:Column ColumnID="mailsubject" Header="主题" DataIndex="mailsubject" Width="200">
                    <Renderer Fn="linkRenderer" />
                </ext:Column>
                <ext:DateColumn ColumnID="sendtime" Header="时间" DataIndex="sendtime" Width="60" Format="yyyy/MM/dd HH:mm:ss" />
            </Columns>
     <%--       <Listeners>
                <WidthChange Handler="updateTotal(#{GridPanel1});" />
            </Listeners>--%>
        </ColumnModel>
       <%-- <Listeners>
            <ColumnResize Handler="updateTotal(#{GridPanel1});" />
            <AfterRender Handler="updateTotal(#{GridPanel1});" Delay="100" />
        </Listeners>--%>
        <View>
            <ext:GroupingView runat="server" ForceFit="true" MarkDirty="false" ShowGroupName="false"
                EnableNoGroups="true" HideGroupedColumn="true">
            </ext:GroupingView>
        </View>
        <TopBar>
            <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>
                    <ext:Button ID="btnDelete" runat="server" Text="删除" Icon="EmailDelete" ToolTip="删除选中邮件">
                        <Listeners>
                            <Click Fn="removeMailOut" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="btnRefresh" runat="server" Text="刷新" Icon="ArrowRefresh" ToolTip="刷新邮件列表">
                        <DirectEvents>
                            <Click OnEvent="btnRefresh_Click">
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
       <%-- <Plugins>
            <ext:GroupingSummary runat="server">
                <Calculations>
                    <ext:JFunction Name="totalCost" Handler="return v + (record.data.Estimate * record.data.Rate);" />
                </Calculations>
            </ext:GroupingSummary>
        </Plugins>--%>
        <SelectionModel>
            <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server">
            </ext:CheckboxSelectionModel>
        </SelectionModel>
    </ext:GridPanel>
    </form>
</body>
</html>
